package com.tboss.template.common.springSecurity;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import com.tboss.template.system.dto.GroupDto;
import com.tboss.template.system.dto.MapGrpFnDto;
import com.tboss.template.system.dto.RoleDto;

@Service
public class SecurityService implements UserDetailsService {

	@Autowired SecurityUserDao userDao;
	
	@Override
	public SecurityUserDto loadUserByUsername(String username)
			throws UsernameNotFoundException, DataAccessException {
		
		SecurityUserDto user = this.userDao.getInfo(username);
		
		return user;
	}

	public List<GroupDto> getGroups(String username){
		return this.userDao.getGroups(username);
	}
	
	public List<RoleDto> getRoles(String username){
		return this.userDao.getRoles(username);
	}
	
	public List<MapGrpFnDto> getMyMenu(String username){
		return this.userDao.getMyMenu(username);
	}
	
	public void initGrpChgChkField(String usrId){
		this.userDao.initGrpChgChkField(usrId);
	}

}
